//
//  UILayer.m
//  HeroNuts
//
//  Created by Magic on 11-3-31.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "UILayer.h"
#import "MenuScene.h"
#import "GameScene.h"


@implementation UILayer



-(id) init
{
	if((self = [super init])) 
	{
        CGSize size = [[CCDirector sharedDirector] winSize];
        
        //set the background of the bottom bar
		CCSprite* bottomBarBackground = [CCSprite spriteWithFile:@"battle_ui.png"];
		bottomBarBackground.anchorPoint = ccp(0,0);
		bottomBarBackground.position = ccp(0,0);
		[self addChild:bottomBarBackground];
        
        //add the items of the bottom bar
        //return button
        CCSprite* return_normal = [CCSprite spriteWithFile:@"Icon.png"]; //(换图片！有木有！！有木有！！！)
        return_normal.color = ccRED;
        CCSprite* return_selected = [CCSprite spriteWithFile:@"Icon.png"]; //(换图片！有木有！！有木有！！！)
        return_selected.color = ccGRAY;
		CCMenuItemImage *menu_image_return = [CCMenuItemImage itemFromNormalSprite:return_normal
                                                                    selectedSprite:return_selected
                                                                           target:self
                                                                         selector:@selector(onReturn)];
        //wait button
        CCSprite* wait_normal = [CCSprite spriteWithFile:@"Icon.png"]; //(换图片！有木有！！有木有！！！)
        wait_normal.color = ccGREEN;
        CCSprite* wait_selected = [CCSprite spriteWithFile:@"Icon.png"]; //(换图片！有木有！！有木有！！！)
        wait_selected.color = ccGRAY;
        CCMenuItemImage *menu_image_wait = [CCMenuItemImage itemFromNormalSprite:wait_normal
                                                                    selectedSprite:wait_selected
                                                                            target:self
                                                                          selector:@selector(onWait)];
        
		CCMenu * bottomBarMenu = [CCMenu menuWithItems:menu_image_return,menu_image_wait,nil];
		[bottomBarMenu alignItemsHorizontallyWithPadding:500];
        bottomBarMenu.anchorPoint = ccp(0,0);
		bottomBarMenu.position = ccp(size.width/2-100.f,31); 
		
        [self addChild:bottomBarMenu];
    }
	return self;
}

-(void) onReturn
{
    [self schedule:@selector(toMenuScene) interval:0.3f];
}

-(void) toMenuScene
{
    [self unscheduleAllSelectors];
    [[CCDirector sharedDirector] replaceScene:[MenuScene scene]];
}

-(void) onWait
{
    //要填充！有木有！！有木有！！！
}

- (void) dealloc
{
	[super dealloc];
}

@end
